package com.isoft.c2team3service2.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.isoft.c2team3service2.dto.StarAvatarDTO;
import com.isoft.c2team3service2.entity.StarAvatar;
import com.isoft.c2team3service2.mapper.StarAvatarMapper;
import com.isoft.c2team3service2.service.StarAvatarService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class StarAvatarServiceImpl implements StarAvatarService {

    private final StarAvatarMapper starAvatarMapper;

    @Override
    public List<StarAvatarDTO> getStarAvatarList() {
        List<StarAvatar> avatarList = starAvatarMapper.selectList(
                new QueryWrapper<StarAvatar>().orderByAsc("sort_order")
        );
        return avatarList.stream()
                .map(avatar -> {
                    StarAvatarDTO dto = new StarAvatarDTO();
                    dto.setImgSrc(avatar.getImgSrc());
                    dto.setName(avatar.getName());
                    return dto;
                })
                .collect(Collectors.toList());
    }
}